@extends('admin.formLayout')
@if(isset($id))
    @section('title','修改用户信息')
@section('barName','修改用户信息')
@else
    @section('title','增加用户')
@section('barName','增加用户')
@endif
@section('content')<form class="layui-form" @if(isset($id)) action="{{route('admin.user_update')}}" @else action="{{route('admin.user_store')}}" @endif method="post">
    {{csrf_field()}}
    @if(isset($id))
        <input type="hidden" name="id" value="{{$id}}">
    @endif

    <div class="layui-form-item">
        <label class="layui-form-label">{{trans('message.avatar')}}</label>
        <div class="layui-input-block">
            @include('admin.form.image',['name'=>'avatar','value'=>isset($model->avatar) ? $model->avatar : ''])
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required"
            value="{{$model->name or ''}}"
                    autocomplete="off" placeholder="请输入姓名" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">{{trans('message.email_filed')}}</label>
        <div class="layui-input-block">
            <input type="text" name="email" lay-verify="email"    @if(isset($id))
            value="{{$model->email}}" disabled
            @endif autocomplete="off" placeholder="请输入邮箱" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" @if(!isset($id)) lay-verify="required" @endif   autocomplete="off" placeholder="请输入密码" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-block">
            <select name="role" >
                <option value="">普通用户</option>
                @foreach($role as $v)
                    <option value="{{$v->name}}" @if(isset($model)&&$model->hasRole($v->name)) selected @endif>{{$v->name}}</option>
                @endforeach
            </select>
        </div>
    </div>
    @if(isset($model))
    <div class="layui-form-item">
        <label class="layui-form-label">前台权限</label>
        <div class="layui-input-block">
                <input type="checkbox" name="allow_login" value="1" title="禁止登陆" @if($model->allow_login==0) checked @endif>
                <input type="checkbox" name="allow_comment"  value="1"  title="禁止评论" @if($model->allow_comment==0) checked @endif>

        </div>
    </div>
    @endif
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="form">立即提交</button>
            <a class="layui-btn layui-btn-primary" href="{{route('admin.user_index')}}">返回</a>
        </div>
    </div>
</form>
@endsection